//package com.dykj.fireFighting.web.mq.consumer.business;
//
//import com.alibaba.fastjson.JSON;
//import com.dykj.fireFighting.api.elasticsearch.devHis.entity.EsDevHis;
//import com.dykj.fireFighting.api.elasticsearch.devHis.service.EsDevHisService;
//import com.dykj.fireFighting.common.core.constant.WebsocketConstant;
//import com.dykj.fireFighting.common.starter.redisson.service.RedisService;
//import com.dykj.fireFighting.web.base.websocket.entity.MoreMessage;
//import com.dykj.fireFighting.web.model.report.DevHis;
//import com.dykj.fireFighting.web.model.vo.MqMessage;
//import com.dykj.fireFighting.web.utils.SpringUtil;
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.common.message.Message;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.UnsupportedEncodingException;
//
//
///**
// * @Author fgc
// * @Date 2021/9/30 10:12
// * @ Description：MQ消息业务处理--设备运行记录入库
// */
//public class FireWebSocketPush extends BusinessProcess{
//    public static final Logger LOGGER = LoggerFactory.getLogger(FireWebSocketPush.class);
//    private static RedisService redisService=(RedisService) SpringUtil.getBean(RedisService.class);
//    public FireWebSocketPush(){
//        super();
//    }
//    @Override
//    public ConsumeConcurrentlyStatus process(Message msg){
//        LOGGER.info("进入websocket推送业务实现");
//        String msgBody= null;
//        try {
//            msgBody = new String (msg.getBody(),"utf-8");
//            System.out.println(msgBody);
//            String key=msg.getKeys();
//            MqMessage mqMessage = JSON.parseObject(msgBody, MqMessage.class);
//            MoreMessage moreMessage=new MoreMessage();
//            moreMessage.setMsgId(mqMessage.getDevHisId());
//            switch (key){
//                case "08"://火警
//                    //websocket推送
//                    moreMessage.setMsgTitle("火警通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_FIRE);
//                    moreMessage.setMsgTxt("您有一条来自" + mqMessage.getDeviceName() + "的火警通知，点击查看！");
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt("您有一条来自" +mqMessage.getUnit().getUnitName()+"的"+ mqMessage.getDeviceName() + "的火警通知，点击查看！");
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//                case "07"://故障
//                    moreMessage.setMsgTitle("故障通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt("您有一条来自" + mqMessage.getDeviceName() + "的故障通知，点击查看！");
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt("您有一条来自" +mqMessage.getUnit().getUnitName()+"的"+ mqMessage.getDeviceName() + "的故障通知，点击查看！");
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//            }
//            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//            return ConsumeConcurrentlyStatus.RECONSUME_LATER;
//        }
//
//    }
//
//}
